package org.apache.seata;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.apache.commons.lang.StringUtils;
import org.apache.seata.core.context.RootContext;
import org.springframework.stereotype.Component;

/**
 * @author 朱海龙
 * 2025/3/9 15:34
 */
@Component
public class FeignInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        String xid = RootContext.getXID();
        if (StringUtils.isNotBlank(xid)) {
            requestTemplate.header(RootContext.KEY_XID, xid);
        }
        requestTemplate.header("castlong", "castlong");
        String url = requestTemplate.url();
        System.out.println(url);
    }
}
